package com.kitty.web.controller;

import com.kitty.web.common.AjaxResult;
import com.kitty.web.core.page.TableDataInfo;
import com.kitty.web.domain.PChengwei;
import com.kitty.web.system.chengwei.service.IPChengweiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 称号配置Controller
 * 
 * @author soul
 * @date 2022-04-08
 */
@Controller
@RequestMapping("/system/chengwei")
public class PChengweiController extends BaseController
{
    private String prefix = "system/chengwei";

    @Autowired
    private IPChengweiService pChengweiService;


    @GetMapping()
    public String chengwei()
    {
        return prefix + "/chengwei";
    }

    /**
     * 查询称号配置列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PChengwei pChengwei)
    {
        startPage();
        List<PChengwei> list = pChengweiService.selectPChengweiList(pChengwei);
        return getDataTable(list);
    }



    /**
     * 新增称号配置
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存称号配置
     */


    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PChengwei pChengwei)
    {
        return toAjax(pChengweiService.insertPChengwei(pChengwei));
    }

    /**
     * 修改称号配置
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PChengwei pChengwei = pChengweiService.selectPChengweiById(id);
        mmap.put("pChengwei", pChengwei);
        return prefix + "/edit";
    }

    /**
     * 修改保存称号配置
     */


    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PChengwei pChengwei)
    {
        return toAjax(pChengweiService.updatePChengwei(pChengwei));
    }

    /**
     * 删除称号配置
     */


    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(pChengweiService.deletePChengweiByIds(ids));
    }
}
